<template>
  <div class="siteMaintenance">
    <!-- 头部 --start-->
    <div class="nav">
      <p>
        <span>.</span>
        {{ pgTitle }}
      </p>
      <div id="nav_go5">
        <el-button
          type="info"
          icon="el-icon-back"
          class="btn_fanhui"
          @click="revert()"
        >返回
        </el-button
        >
      </div>
    </div>
    <!--主题内容部分开始-->
    <div class="Main">
      <p>基本信息</p>
      <div class="header">
        <ul>
          <li>
            <span>站点编号</span>
            <el-input style="width: 70%;" v-model="from_site.siteNumber" disabled></el-input>
          </li>
          <li>
            <span>站点名称</span>
            <el-input style="width: 70%;" v-model="from_site.siteName" disabled></el-input>
          </li>
          <li>
            <span>站点地址</span>
            <el-input style="width: 70%;" v-model="from_site.siteAddress" disabled></el-input>
          </li>
          <li>
            <span>法人</span>
            <el-input style="width: 70%;" v-model="from_site.legalPerson" disabled></el-input>
          </li>
          <li>
            <span>联系方式</span>
            <el-input style="width: 70%;" v-model="from_site.legalpersonPhone" disabled></el-input>
          </li>
          <li>
            <span>站点负责人</span>
            <el-input style="width: 70%;" v-model="from_site.siteResponsible" disabled></el-input>
          </li>
          <li>
            <span>站点负责人联系方式</span>
            <el-input style="width: 70%;" v-model="from_site.account" disabled></el-input>
          </li>
          <li>
            <span>所在区域</span>
            <el-input style="width: 70%;" v-model="from_site.area" disabled></el-input>
          </li>
          <li>
            <span>区域负责人</span>
            <el-input style="width: 70%;" v-model="from_site.areaResponsible" disabled></el-input>
          </li>
          <li>
            <span>区域负责人联系方式</span>
            <el-input style="width: 70%;" v-model="from_site.areaResponsiblePhone" disabled></el-input>
          </li>
          <li>
            <span>开户行</span>
            <el-input style="width: 70%;" v-model="from_site.accountBank" disabled></el-input>
          </li>
          <li>
            <span>开户账号</span>
            <el-input style="width: 70%;" v-model="from_site.accountOpen" disabled></el-input>
          </li>
          <li>
            <span>纳税人识别号</span>
            <el-input style="width: 70%;" v-model="from_site.taxpayerNumber" disabled></el-input>
          </li>
          <li>
            <span>账户名称</span>
            <el-input style="width: 70%;" v-model="from_site.account" disabled></el-input>
          </li>
          <li>
            <span>密码</span>
            <el-input style="width: 70%;" v-model="from_site.password" disabled></el-input>
          </li>
        </ul>
      </div>
      <p>上传图片</p>
      <div class="intermediate">
        <ul>
          <li>
            <span>现场照片 :</span>
            <div style="width: 148px;height: 148px;display: inline-block;overflow: hidden">
              <el-image v-for=" it in imglist" :key="it" :src="it" style="width: 140px; height: 140px"></el-image>
            </div>
          </li>
          <li>
            <span>合同照片 :</span>
            <div style="width: 148px;height: 148px;display: inline-block;overflow: hidden">
              <el-image v-for=" it in imgArr" :key="it" :src="it" style="width: 140px; height: 140px"></el-image>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!--底部按钮-->
    <div class="bottom">
      <el-button type="primary" size="medium" @click="tongguo()" v-if="statue == '1' || statue=='false'">确定
      </el-button>
      <el-button size="medium" @click="dialogVisible = true" v-if="statue == '1' || statue=='false'">驳回</el-button>
      <el-button type="info" size="medium" @click="revert()" v-if="statue == '2' ||statue=='true'">返回</el-button>
    </div>
    <!-- 底部按钮 --end-->
    <el-dialog
      title="驳回"
      :visible.sync="dialogVisible"
      width="30%"
      :modal-append-to-body="false">
      <span>驳回理由 : </span>
      <el-input style="width: 80%" v-model="bohui" placeholder="请输入驳回理由"></el-input>
      <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialogVisible = false ,getbo()">确 定</el-button>
    <el-button @click="dialogVisible = false">取 消</el-button>
  </span>
    </el-dialog>
  </div>
</template>


<script>
import axios from "axios";

export default {


  data() {
    return {
      dialogVisible:false,
      from_site: {},
      bohui:"",
      pgTitle:"站点详情",
      imglist:[],
      imgArr:[],
    };
  },
  created() {
    this.userId = JSON.parse(localStorage.getItem("message")).Id;
    this.userName = JSON.parse(localStorage.getItem("message")).Name;
    this.statue = this.$route.query.statue;
    this.shengheMessageId = this.$route.query.id
    this.checkFlowId = this.$route.query.checkFolwId
    console.log(this.userId, this.shengheMessageId)
    if (this.statue == "2" || this.statue == "true") {
      this.pgTitle = "站点详情";
    } else if (this.statue == "1" || this.statue == "false") {
      this.pgTitle = "站点审核";
    }
    this.getList()
  },
  methods: {
    getList() {
      axios
      (
        "/JX_java/procurement/caigoushenghe/getshengHeDetails?shengheMessageId=" + this.shengheMessageId + "&&checkFlowId=" + this.checkFlowId
      )
        .then((res) => {
          this.imglist = []
          this.imgArr = []
          this.from_site = res.data.data.pojo;
          let tempaarr = JSON.parse(res.data.data.pojo.xianzhaozhaopian)
          for (let i = 0; i < tempaarr.length; i++) {
            if (tempaarr[i] || null != null) {
              this.imglist.push(tempaarr[i].url)
            }
          }
          let TempList = JSON.parse(res.data.data.pojo.contract)
          for (let i = 0; i < TempList.length; i++) {
            if (TempList[i] || null != null) {
              this.imgArr.push(TempList[i].url)
            }
          }
        });
    },
    //通过
    tongguo() {
      const arr = {
        "bohui": "",
        "checkFolwId": this.$route.query.checkFolwId,
        "shengheMessageId": this.$route.query.id,
        "status": 3,
        "userId": this.userId,
        "userName": this.userName
      }
      // return
      axios
        .post(
          "/JX_java/procurement/caigoushenghe/updatestatus", arr
        )
        .then((res) => {
          if (res.data.data == "操作成功") {
            this.$message.success(res.data.data);
            this.$router.go(-1);
          } else {
            this.$message.error(res.data.data);
          }
        });
    },

    // 驳回函数
    getbo() {
      if (this.bohui == "") {
        this.$message.error("驳回理由不能为空！");
        return;
      }
      const arr = {
        "bohui": this.bohui,
        "checkFolwId": this.$route.query.checkFolwId,
        "shengheMessageId": this.$route.query.id,
        "status": 2,
        "userId": this.userId,
        "userName": this.userName,
      }
      // return
      axios
        .post(
          "/JX_java/procurement/caigoushenghe/updatestatus", arr
        )
        .then((res) => {
          if (res.data.data == "操作成功") {
            this.$message.success(res.data.data);
            this.$router.go(-1);
          } else {
            this.$message.error(res.data.data);
          }
        });
    },
    //返回
    revert() {
      this.$router.go(-1);
    },
  }

}

</script>
<style lang="scss" scoped>
@import "@/assets/scss/base.scss";

.nav {
  height: 60px;
  padding: 0 1%;
  position: relative;

  p {
    height: 40px;
    margin: 10px 0;
    line-height: 40px;

    span {
      background: $Header_color;
      color: $Header_color;
    }
  }

  #nav_go5 {
    position: absolute;
    top: 10px;
    right: 1%;

    img {
      height: 16px;
      padding-right: 10px;
    }
  }
}

.Main {
  width: 98%;
  //margin-left: 10px;
  margin: auto;
  background: #fff;

  p {
    //text-align: center;
    font-weight: 700;
    font-size: 20px;
    border-bottom: 1px solid rgb(220, 222, 226);
    width: 98%;
    margin-left: 15px;
    padding-bottom: 15px;
    padding-top: 15px;
  }

  .header {
    //border-bottom: 1px solid rgb(220, 222, 226);
    width: 98%;
    //margin-left: 15px;
    padding-bottom: 20px;
    margin: auto;

    ul {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      color: #909399;
      margin-top: 20px;

      li {
        width: 33%;
        font-size: 14px;
        margin-bottom: 10px;
        text-align: center;

        span {
          display: inline-block;
          width: 28%;
        }
      }
    }
  }

  .intermediate {
    //border-bottom: 1px solid rgb(220, 222, 226);
    width: 98%;
    //margin-left: 15px;
    margin: auto;
    padding-bottom: 20px;

    ul {
      margin-top: 20px;
      width: 100%;
      display: flex;
      flex-wrap: wrap;

      li {
        width: 45%;
        font-size: 14px;
        margin-bottom: 10px;
        margin-right: 20px;
        display: flex;
        align-items: flex-start;

        span {
          display: inline-block;
          margin-right: 10px;
          font-size: 16px;
        }
      }
    }
  }
}

.bottom {
  padding-top: 20px;
  text-align: center;
}
</style>
